{include file="common/header"}
<body>
<form class="layui-form" action="">
    <div class="mainBox">
        <div class="main-container">
            <div class="layui-form-item">
                <label class="layui-form-label"><font color="red">*</font>分类名称</label>
                <div class="layui-input-block">
                    <input type="text" name="category_title" class="layui-input" lay-verify="required">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label"><font color="red"></font>分类备注</label>
                <div class="layui-input-block">
                    <input type="text" name="category_remark" class="layui-input" value="">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label"><font color="red">*</font>分类排序</label>
                <div class="layui-input-block">
                    <input type="text" name="category_sort" class="layui-input" value="10">
                </div>
                <div class="layui-tips">数字越大越靠前</div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label"><font color="red">*</font>分类状态</label>
                <div class="layui-input-block">
                    <input type="radio" name="category_status" value="1" title="启用" checked>
                    <input type="radio" name="category_status" value="0" title="禁用">
                </div>
            </div>
        </div>
    </div>
    <div class="bottom">
        <div class="button-container" style="left: 30px">
            <input type="hidden" name="__token__" id="__token__" value="{:token()}"/>
            <input type="hidden" name="id" value="{$data['id']??''}">
            <button type="button" class="layui-btn layui-btn-normal layui-btn-sm" lay-submit="" lay-filter="save">
                <i class="layui-icon layui-icon-ok"></i>
                提交
            </button>
            <button type="reset" class="layui-btn layui-btn-primary layui-btn-sm">
                <i class="layui-icon layui-icon-refresh"></i>
                重置
            </button>
        </div>
    </div>
</form>

<script>
    layui.use(['form', 'jquery', 'common'], function () {
        let form = layui.form;
        let $ = layui.jquery;
        let common = layui.common;
        form.on('submit(save)', function (data) {
            $.ajax({
                data: JSON.stringify(data.field),
                dataType: 'json',
                contentType: 'application/json',
                type: 'post',
                success: function (res) {
                    if (res.code == 200) {
                        layer.msg(res.msg, {icon: 1, time: 1000}, function () {
                            parent.layer.close(parent.layer.getFrameIndex(window.name));//关闭当前页
                            parent.layui.table.reload("dict-table");
                        });
                    } else {
                        layer.msg(res.msg, {icon: 2, time: 1000}, function () {
                            common.getToken("{$Request.root}");
                        });
                    }
                }
            })
            return false;
        });
    })
</script>
</body>
</html>